from datetime import datetime

import sqlalchemy
from sqlalchemy.orm import declarative_base, sessionmaker

# 数据库模型
Base = declarative_base()


class User(Base):
    __tablename__ = "users"
    id = sqlalchemy.Column(sqlalchemy.String, primary_key=True, index=True)
    username = sqlalchemy.Column(sqlalchemy.String, unique=True, index=True)
    hashed_password = sqlalchemy.Column(sqlalchemy.String)
    is_active = sqlalchemy.Column(sqlalchemy.Boolean, default=True)
    created_at = sqlalchemy.Column(sqlalchemy.DateTime, default=datetime.now())


class FaceRecord(Base):
    __tablename__ = "face_records"
    id = sqlalchemy.Column(sqlalchemy.String, primary_key=True, index=True)
    user_id = sqlalchemy.Column(sqlalchemy.Integer, index=True)
    user_name = sqlalchemy.Column(sqlalchemy.String)
    image_url = sqlalchemy.Column(sqlalchemy.String)  # 新增图片URL字段
    created_at = sqlalchemy.Column(sqlalchemy.DateTime, default=datetime.now())
    updated_at = sqlalchemy.Column(sqlalchemy.DateTime, default=datetime.now())
    created_user = sqlalchemy.Column(sqlalchemy.String)
    updated_user = sqlalchemy.Column(sqlalchemy.String)
